package com.example.a511;

import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.SimpleAdapter;
import android.widget.Spinner;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;

public class SpinnerItemActivity extends AppCompatActivity {
    private Spinner spinner ;
    private static final int[] ico = new int[]{
            R.mipmap.aa,R.mipmap.bb,R.mipmap.cc,R.mipmap.dd,R.mipmap.da
    };
    private static final String [] name = new String[]{
        "皮卡丘","动画片","新动画片","哆啦","新动画片篇","MM"
    };
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        setContentView(R.layout.activity_spinner_item);

        spinner = findViewById(R.id.sp_icon);
        List<Map<String, Object>> data = new ArrayList<>();
        for (int i = 0;i < ico.length;i++){
            Map<String,Object> map = new HashMap<>();

            map.put("ico",ico[i]);
            map.put("name",name[i]);
            data.add(map);
        }
        SimpleAdapter adapter = new SimpleAdapter(this,data,R.layout.icon_spinner
                ,new String[]{"ico","name"}
                ,new int[]{R.id.icon_spinner,R.id.tv_content});
        spinner.setAdapter(adapter);
    }
}